//
// Created by Scave on 2025/8/22.
//

#ifndef RIDER3D_RESOURCE_H
#define RIDER3D_RESOURCE_H

#include "Define.h"
#include "component/Supposition.h"

NS_RIDER_BEGIN
    const static TEXTURE_ID_TYPE kInvalidIndex = UINT16_MAX;

    struct Texture2D {
    public:
        Texture2D();

        Texture2D(TEXTURE_ID_TYPE id);

        TEXTURE_ID_TYPE GetId() const;

        bool IsValid();

    private:
        TEXTURE_ID_TYPE id_{kInvalidIndex};
    };

    struct Material {
        // 表面颜色，和表面纹理只能二选一
        Color color;
        // 表面贴图纹理，也是漫反射纹理
        Texture2D main_texture;
        // 镜面光纹理
        Texture2D specular_texture;
        // 法线纹理
        Texture2D normal_texture;
        // 金属度
        float metallic{0};
        // 光滑度
        float smoothness{1};
    };

    class ResourceManager {
    public:
        /// 创建纹理，如果有就直接get
        /// \param path 纹理图片路径
        /// \return
        Texture2D CreateOrGetTexture(const String& path);

        /// 直接创建带表面纹理的Material
        /// \param path 纹理图片路径
        /// \return
        Material CreateColorMaterial(Color color);

        /// 直接创建带表面纹理的Material
        /// \param path 纹理图片路径
        /// \return
        Material CreateTextureMaterial(const String& path);
    private:
        HASHMAP<String, Texture2D> path_texture_map_;
    };

NS_RIDER_END

#endif //RIDER3D_RESOURCE_H
